package com.situ.web.demo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.junit.Test;

import com.situ.web.entity.Student;





public class Demo {
	@Test
	public void test1() {
		   List<Student> list = new ArrayList<Student>();
		   //ArrayList<Student> list = new ArrayList<Student>();
		   Student student1 = new Student(1, "张三1", 20, "男");
		   Student student2 = new Student(2, "张三2", 20, "男");
		   Student student3 = new Student(3, "张三3", 20, "男");
		   list.add(student1);
		   list.add(student2);
		   list.add(student3);
		   list.add(student1);
		   for (Student student : list) {
		     System.out.println(student);
		   }
		   System.out.println("==================");
		   Set<Student> set = new HashSet<Student>();
		   //HashSet<Student> set = new HashSet<Student>();
		   set.add(student1);
		   set.add(student2);
		   set.add(student3);
		   set.add(student1);
		   for (Student student : set) {
		     System.out.println(student);
		   }
		   
		}
	@Test
	public void test2() {
		//
		//
		//
		//
		Map<String, String> map = new HashMap<String, String>();
		map.put("CN", "中华人民共和国");
		map.put("US", "美国");
		//
		String value1 = map.get("CN");
		System.out.println(value1);
		String value2 = map.get("US");
		System.out.println(value2);
		//Map遍历
		// Entry 是对key-value的封装
		Set<Entry<String, String>> set =  map.entrySet();
		for (Entry<String, String> entry : set) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println("key :" + key + ", value:" + value);
		}
	}

}
